home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / music / 13 / utility / prnsrc.pas < prev    next >
Pascal/Delphi Source File  |  1986-05-12  |  9KB  |  218 lines

  1. PROGRAM Print_Source;
  2. { This program prints the Pascal source code from the Personal Pascal }
  3. { Manager instead of going back to the Desk Top }
  4. { Written by Dan McKee, PPN 75766,1515 }
  5. CONST
  6.      three = 3;
  7. {$I GEMCONST.PAS}
  8.  
  9. TYPE
  10.  
  11. {$I GEMTYPE.PAS}
  12.  
  13. VAR
  14.    Path, Name : Path_Name;
  15.    msg : Message_Buffer;
  16.    menu : Menu_Ptr;
  17.    Author_Box,Print_Box,Help_Box : Dialog_Ptr;
  18.    dummy,file_title,open_item,print_item,help_title,Author_Item,ok_button,
  19.    help_item, quit_item,sf,show_it,pushed,h_i,get_file,cancel_button
  20.    : integer;
  21.  
  22. {$I GEMSUBS.PAS}
  23.  
  24. { Dialog box for printing a file or cancel printing }
  25.  
  26. PROCEDURE Print_Info;
  27.  
  28. BEGIN
  29.         sf := System_Font;
  30.         Print_Box := New_Dialog(15,0,0,40,9);
  31.         Print_Item := Add_DItem(Print_Box,G_Text,None,2,1,36,1,0,$1180);
  32.         Set_DText(Print_Box,Print_Item,'Printing....',sf,TE_Center);
  33.         Print_Item := Add_DItem(Print_Box,G_Text,None,2,3,36,1,0,$1180);
  34.         SET_DText(Print_Box,Print_Item,Name,sf,TE_Center);
  35.         ok_button := Add_DItem(Print_Box,G_Button,Selectable|Exit_Btn|Default,
  36.                   5,5,8,2,2,$1180);
  37.         Set_DText(Print_Box,ok_button,'OK',sf,TE_Center);
  38.         cancel_button := Add_DItem(Print_Box,G_Button,Selectable|Exit_Btn,
  39.                          27,5,8,2,2,$1180);
  40.         Set_DText(Print_Box,cancel_button,'Cancel',sf,TE_Center);
  41.         Center_Dialog(Print_Box);
  42.         Show_It := Do_Dialog(Print_Box,0);
  43.  
  44. END; {Print_Info}
  45.  
  46. { to print or not to print! }
  47.  
  48. PROCEDURE Print_It;
  49.           BEGIN
  50.                { get the dialog box }
  51.                Print_Info;
  52.                { check to see if the ok_button was selected }
  53.                IF Obj_State(Print_Box,ok_button) <> 0 THEN
  54.                  BEGIN
  55.                { set the default input from the keyboard to the disk }
  56.                  reset( INPUT, Name );
  57.                { set the default output from the screen to the printer }
  58.                  REWRITE(OUTPUT,'PRN:');
  59.                { loop for print the file until the end-of-file character }
  60.                  WHILE NOT EOF DO
  61.                                  BEGIN
  62.                                       readln(Name);
  63.                                       WRITELN(NAME);
  64.                                  END;
  65.                                  End_Dialog(Print_Box);
  66.                  END;
  67.                { check to see if the cancel_button was selected }
  68.                IF Obj_state(Print_Box,cancel_button) <> 0 THEN
  69.                 End_Dialog(Print_Box);
  70.           END; { Print_It }
  71.  
  72. { this module set the path directory with the extender of '.PAS' }
  73.  
  74. PROCEDURE Draw_It;
  75.             BEGIN
  76.                  { set a default path }
  77.                  Path := 'A:\*.PAS';
  78.                  { Draw predefined dialog box for listing source files }
  79.                   IF Get_In_File(Path,Name) THEN
  80.                   { file name select, let's go print it! }
  81.                   Print_It
  82.                   { cancel button pressed, erase dialog box }
  83.                   ELSE;
  84.              END; { Draw_It }
  85.  
  86. { dialog box for displaying the programmer and giving credits }
  87.  
  88. PROCEDURE Author_Info;
  89.  
  90. BEGIN
  91.         sf := System_Font;
  92.         Author_Box := New_Dialog(15,0,0,40,18);
  93.         Author_Item := Add_DItem(Author_Box,G_Text,None,2,1,36,1,0,$1180);
  94.         Set_DText(Author_Box,Author_Item,'Print Source',sf,TE_Center);
  95.         Author_item := Add_DItem(Author_Box,G_Text,None,2,2,36,1,0,$1180);
  96.         Set_DText(Author_Box,Author_Item,'By',sf,TE_Center);
  97.         Author_item := Add_DItem(Author_Box,G_Text,None,2,3,36,1,0,$1180);
  98.         Set_DText(Author_Box,Author_Item,'Daniel H. McKee',sf,TE_Center);
  99.         Author_item := Add_DItem(Author_Box,G_Text,None,2,5,36,1,0,$1180);
  100.         Set_DText(Author_Box,Author_Item,'Compuserve - PPN 75766,1515',
  101.                   sf,TE_Center);
  102.         Author_item := Add_DItem(Author_Box,G_Text,None,2,6,36,1,0,$1180);
  103.         Set_DText(Author_Box,Author_Item,'Delphi - elmac',sf,TE_Center);
  104.         Author_item := Add_DItem(Author_Box,G_Text,None,2,8,36,1,0,$1180);
  105.         Set_DText(Author_Box,Author_Item,'Using',sf,TE_Center);
  106.         Author_item := Add_DItem(Author_Box,G_Text,None,2,10,36,1,0,$1180);
  107.         Set_DText(Author_Box,Author_Item,'Personal Pascal',sf,TE_Center);
  108.         Author_item := Add_DItem(Author_Box,G_Text,None,2,11,36,1,0,$1180);
  109.         Set_DText(Author_Box,Author_Item,'Copyright (c) 1986 OSS & CCD',
  110.                   sf,TE_Center);
  111.         ok_button := Add_DItem(Author_Box,G_Button,Selectable|Exit_Btn|Default,
  112.                   15,15,8,2,2,$1180);
  113.         Set_DText(Author_Box,ok_button,'OK',sf,TE_Center);
  114.         Center_Dialog(Author_Box);
  115.         Show_It := Do_Dialog(Author_Box,0);
  116.         End_Dialog(Author_Box);
  117.  
  118. END;{Author_Info}
  119.  
  120. { dialog box for program instructions }
  121.  
  122. PROCEDURE Do_Help;
  123.  
  124. BEGIN
  125.         sf := System_Font;
  126.         Help_Box := New_Dialog(15,0,0,72,14);
  127.         h_i := Add_DItem(Help_Box,G_Text,None,2,2,68,1,0,$1180);
  128.         Set_DText(Help_Box,h_i,
  129.         ' This program is design to print the scorce code from Personal',
  130.         sf,TE_Left);
  131.         h_i := Add_DItem(Help_Box,G_Text,None,2,3,68,1,0,$1180);
  132.         Set_DText(Help_Box,h_i,
  133.         ' Pascal Manager, but can be run from the Gem Desk Top if desired. ',
  134.         sf,TE_Left);
  135.         h_i := Add_DItem(Help_Box,G_Text,None,2,4,68,1,0,$1180);
  136.         Set_DText(Help_Box,h_i,
  137.         ' To print out your desired code, move the mouse to the menu bar',
  138.         sf,TE_Left);
  139.         h_i := Add_DItem(Help_Box,G_Text,None,2,5,68,1,0,$1180);
  140.         Set_DText(Help_Box,h_i,
  141.         ' "File" and click on the "Open File" option. The program is self-',
  142.         sf,TE_Left);
  143.         h_i := Add_DItem(Help_Box,G_Text,None,2,6,68,1,0,$1180);
  144.         Set_DText(Help_Box,h_i,
  145.         ' explanatory from this point. If you have a second disk or ram disk,',
  146.         sf,TE_Left);
  147.         h_i := Add_DItem(Help_Box,G_Text,None,2,7,68,1,0,$1180);
  148.         Set_DText(Help_Box,h_i,
  149.         ' you can change the default drive by pointing the mouse to the ',
  150.         sf,TE_Left);
  151.         h_i := Add_DItem(Help_Box,G_Text,None,2,8,68,1,0,$1180);
  152.         Set_DText(Help_Box,h_i,
  153.         ' Directory, click the mouse, backspace, type in desired path, and',
  154.         sf,TE_Left);
  155.         h_i := Add_DItem(Help_Box,G_Text,None,2,9,68,1,0,$1180);
  156.         Set_DText(Help_Box,h_i,
  157.         ' then move the mouse to the filenames, then click the mouse. Enjoy!',
  158.         sf,TE_Left);
  159.         ok_button := Add_DItem(Help_Box,G_Button,Selectable|Exit_Btn|Default,
  160.                   30,11,8,2,2,$1180);
  161.         Set_DText(Help_Box,ok_button,'OK',sf,TE_Center);
  162.         Center_Dialog(Help_Box);
  163.         show_it := Do_Dialog(Help_Box,0);
  164.         End_Dialog(Help_Box);
  165.  
  166. END; {Do_Help}
  167.  
  168.  { this module checks the menu bar for the option selected }
  169.  
  170.     PROCEDURE Do_menu(title,item : integer);
  171.  
  172.  BEGIN
  173.        BEGIN
  174.          IF title = three THEN
  175.                               Author_Info
  176.          ELSE IF item = open_item THEN
  177.                               Draw_it
  178.          ELSE IF item = help_item THEN
  179.                               Do_Help
  180.          ELSE IF item = quit_item THEN
  181.        END;
  182.        Menu_Normal(menu,title);
  183.  END; { Do_Menu }
  184.  
  185. { loop for getting a message }
  186.  
  187. PROCEDURE Event_Loop;
  188.    VAR
  189.       which : integer;
  190.       msg : Message_Buffer;
  191.  
  192.    BEGIN
  193.         REPEAT
  194.  
  195.               which := Get_Event(E_Message,0,0,0,0,false,0,0,0,0,false,
  196.                                  0,0,0,0,msg,dummy,dummy,dummy,dummy,
  197.                                  dummy,dummy);
  198.               Do_Menu( Msg[3], Msg[4]);
  199.               UNTIL msg[4] = quit_item;
  200.    END; { Event_Loop }
  201.  
  202. BEGIN { Main Program }
  203.     IF Init_Gem >= 0 THEN
  204.        BEGIN
  205.             menu := New_Menu( 6, ' file printer ' );
  206.             file_title := Add_MTitle( menu, ' File ' );
  207.             Help_title := Add_MTitle( menu, ' Help ' );
  208.             open_item := Add_MItem ( menu, file_title, ' Open File ' );
  209.             help_item := Add_MItem ( menu, help_title, ' Info ');
  210.             quit_item := Add_MItem ( menu, file_title, ' Quit      ' );
  211.             Draw_Menu( menu );
  212.             Event_Loop;
  213.             Erase_Menu ( menu);
  214.             Exit_Gem;
  215.        END
  216. END. { Main }
  217. BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
  218. ə